package system.service;

import system.dao.StudentDAO;
import system.pojo.Student;

import java.sql.SQLException;
import java.util.List;

public class StudentService {
    private StudentDAO studentDAO;

    public StudentService() {
        studentDAO = new StudentDAO();
    }

    public void addStudent(Student student) throws SQLException {
        studentDAO.addStudent(student);
    }

    public void updateStudent(Student student) throws SQLException {
        studentDAO.updateStudent(student);
    }

    public void deleteStudent(int id) throws SQLException {
        studentDAO.deleteStudent(id);
    }

    public Student getStudent(int id) throws SQLException {
        return studentDAO.getStudent(id);
    }

    public List<Student> getAllStudents() throws SQLException {
        return studentDAO.getAllStudents();
    }

    public List<Student> searchStudents(String keyword) throws SQLException {
        return studentDAO.searchStudents(keyword);
    }

    public List<Student> searchStudentsByPage(String keyword, int page, int pageSize) throws SQLException {
        return studentDAO.searchStudentsByPage(keyword, page, pageSize);
    }

    public int getTotalStudents(String keyword) throws SQLException {
        return studentDAO.getTotalStudents(keyword);
    }
}
